var creatContentObject = function (template, event) {
    var $parent = null;
    var view = function () { };

    // view.prototype.$id = id;
    for (const key in event) {
        if (event.hasOwnProperty(key)) {
            const element = event[key];
            if (key != 'render' || key != 'destroy') {
                view.prototype[key] = element
            };
        }
    };

    view.prototype.$render = event.render;
    view.prototype.$destroy = event.destroy || function () { };

    // 扩展对象渲染方法
    view.prototype.render = function (parent) {
        $parent = parent
        this.$parent = parent;
        view.prototype.$el = $(template);
        parent.append(this.$el);
        this.$render.apply(this);
    };

    // 扩展对象注销方法
    view.prototype.destroy = function () {
        this.$destroy.apply(this);
        this.$el.remove();
    };

    view.prototype.reload = function () {
        this.destroy();
        this.render($parent);
    };

    return new view();
};

export default creatContentObject
